package com.yami.shop.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yami.shop.bean.app.dto.CouponOrderDto;
import com.yami.shop.bean.dto.TtlCoupon;
import com.yami.shop.bean.model.Coupon;
import com.yami.shop.bean.model.UserCoupon;
import com.yami.shop.dao.CouponMapper;
import com.yami.shop.dao.UserCouponMapper;
import com.yami.shop.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CouponServiceImpl extends ServiceImpl<CouponMapper, Coupon> implements CouponService {

    @Autowired
    private CouponMapper couponMapper;

    @Autowired
    private UserCouponMapper userCouponMapper;
    @Override
    public void insertCoupon(Coupon coupon) {
        couponMapper.insert(coupon);
    }

    @Override
    public List<Coupon> getAllCoupon() {
        return couponMapper.selectList(null);
    }

    @Override
    public List<Coupon> getValCoupon(String userId) {
        return couponMapper.selectValCoupon(userId);
    }

    @Override
    public Coupon getCouponById(Long couponId) {

        return couponMapper.selectCouponByCouponId(couponId);
    }


    @Override
    public List<Coupon> getUserCoupon(String userId) {

        return couponMapper.selectUserCoupon(userId);
    }

    @Override
    public List<TtlCoupon> getTtlCoupon(String userId) {
        return couponMapper.selectTtlCoupon(userId);
    }

    @Override
    public List<CouponOrderDto> getCouponOrderDto(String userId) {
        return couponMapper.selectCouponOrder(userId);
    }

    @Override
    public CouponOrderDto getCouponOrderDtoByCouponId(Long couponId) {
        return couponMapper.selectCouponOrderByCouponId(couponId);
    }

    @Override
    public void changeCouponStatus(Long couponId, Boolean status) {
        couponMapper.updateCouponStatus(couponId, status);
    }
}
